package linuxbox.news.servlet;

import javax.servlet.http.*;

import linuxbox.common.BoxSession;
import linuxbox.common.Action;

public class BoxNewsAdminSettingsAction extends Action {
    protected static String viewJSP = null;
    protected static String editJSP = null;

    public void doAction(HttpSession aSession, BoxSession aBoxSession,
            HttpServletRequest req, HttpServletResponse resp) throws Exception {
        String str = req.getParameter("SubmitCancel");
        if (str != null) {
            sendFile(viewJSP, req, resp);
            return;
        }

        str = (String) req.getParameter("SubmitSave");
        if (str != null) {
            aBoxSession.setConfigInt("news", "Admin", "Entries Per Page",
                    Integer.parseInt((req.getParameter("ENTRIES_PER_PAGE"))));
            sendFile(viewJSP, req, resp);
            return;
        }

        str = (String) req.getParameter("SubmitEdit");
        if (str != null) {
            str = aBoxSession.getConfigString("news", "Admin",
                    "Entries Per Page");
            if (str == null || str.length() == 0)
                str = "20";
            req.setAttribute("ENTRIES_PER_PAGE", str);
            sendFile(editJSP, req, resp);
            return;
        }
        sendFile(viewJSP, req, resp);
    }

    public void setViewJSP(String str) {
        viewJSP = str;
    }

    public void setEditJSP(String str) {
        editJSP = str;
    }
}
